﻿using System;
using CoreEx.MicroMapper;
using LinFu.IoC.Configuration;
using LinFu.IoC.Interfaces;
using CoreEx.Database.Metadata;

namespace CoreEx.Database.MetaData.Implementation
{
    /// <summary>
    /// Provides a default <see cref="ITableMapper{TTarget}"/>.
    /// </summary>
    [Factory(typeof(ITypeInfoMapper_old<>))]
    public class TypeInfoMapperFactory_old : IFactory
    {
        public object CreateInstance(IFactoryRequest request)
        {            
            Type mapperType = typeof(TypeInfoMapper_old<>);
            Type genericMapperType = mapperType.MakeGenericType(request.ServiceType.GetGenericArguments());
            object instance = Activator.CreateInstance(genericMapperType,request.Arguments);
            return instance;
        }
    }
}
